package details;

import java.io.IOException;
import java.util.ArrayList;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;
//import java.util.Iterator;

import specialfeatures.Features;

/**
 * @author Tami
 *
 */
public class Cd {
	
	public static String VARIOUS = "various";
	
	private String genre;
	private ArrayList<Track> tracks;
	private String title;
	private int performerID;
	private String performer;
	private int releaseYear;
	private String albom_id;/* discId+genre */
	
	private int lengthInSec;
	private int likes;
	private int views;
	
	private ArrayList<String> lyrics = new ArrayList<String>();
	
	
	public ArrayList<String> getLyrics() {
		return lyrics;
	}

	
	
	public void addlyrics() throws IllegalStateException, IOException, ParserConfigurationException, SAXException, InterruptedException
	{
		Features feature=new Features();
		
		for  (int i=0; i<tracks.size();i++)
		{
			
			lyrics.add(feature.getLyrics(tracks.get(i).getArtistName(), tracks.get(i).getTitle()));
		}
	}
	
	
	public Cd(String title,String albom_id,int performerID, String performer ,int releaseYear,int lengthInSec,String genre,int likes,int views){
	
		this.title = title;
	
		this.releaseYear = releaseYear;
		this.albom_id = albom_id;
		this.setGenre(genre);
		this.setTracks(new ArrayList<Track>());
		this.lengthInSec = lengthInSec;
		this.setPerformer(performer);
		this.setPerformerID(performerID);
		
		this.likes = likes;
		this.views = views;
		
	}
	
	
	public Cd() {
		// TODO Auto-generated constructor stub
	}


	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	
	public int getReleaseYear() {
		return releaseYear;
	}
	public void setReleaseYear(int releaseYear) {
		this.releaseYear = releaseYear;
	}
	
	
	
	public void addTrack(Track track) {
		this.tracks.add(track);
	}
	

	public String getAlbom_id() {
		return albom_id;
	}


	public void setAlbom_id(String albom_id) {
		this.albom_id = albom_id;
	}

	
	public int getLengthInSec() {
		return this.lengthInSec;
	}
	public void setLengthInSec(int lengthInSec) {
		this.lengthInSec = lengthInSec;
	}
	
	public int getPerformerID() {
		return performerID;
	}


	public void setPerformerID(int performer) {
		this.performerID = performer;
	}


	public String getPerformer() {
		return performer;
	}


	public void setPerformer(String performer) {
		this.performer = performer;
	}


	public ArrayList<Track> getTracks() {
		return tracks;
	}


	public void setTracks(ArrayList<Track> tracks) {
		this.tracks = tracks;
	}


	public String getGenre() {
		return genre;
	}


	public void setGenre(String genre) {
		this.genre = genre;
	}
	
	
	public int getLikes() {
		return likes;
	}


	public void setLikes(int likes) {
		this.likes = likes;
	}


	public int getViews() {
		return views;
	}


	public void setViews(int views) {
		this.views = views;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	public	String	toString()	
	{
		String toS = "Disc Title: " + this.title;

		if (this.performer!= VARIOUS)        
		{
			
			toS += " Artist : " + this.performer+"\n ";
			
		}
		else
		{
			toS += " Artists: " + "N/A" + "\n ";
		}

		if (this.releaseYear != 0)
		{
			toS += " Year: " + this.releaseYear + "\n ";
		}
		else
		{
			toS += " Year: " + "N/A" + "\n ";
		}
		
		if (this.genre != null && !this.genre.isEmpty())
		{
			toS += " Genres: " + genre + "\n ";
			
		}
		toS += " length: " + this.lengthInSec + " seconds\n ";
		toS += " Likes " + this.likes + "\n ";
		toS += " Views " + this.views + "\n ";
		
		for (Track track : this.tracks)
		{
			toS += "   " + track.toString() + "\n ";
		}
		return toS;
	}


	


	

	

	
}

